﻿//-----------------------------------------------------------------------
// <copyright file="Copyright.cs" author="Michael Herndon">
//     Copyright (c) CompanyName.  All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace Amplify.Twitter
{
	#region Using Statements
	using System;
	using System.Collections.Generic;
	using System.Linq;
	using System.Text;

	using MbUnit.Framework;
	using Gallio.Framework;

	using Describe = MbUnit.Framework.TestsOnAttribute;
	using InContext = MbUnit.Framework.DescriptionAttribute;
	using It = MbUnit.Framework.TestAttribute;
	using Should = MbUnit.Framework.DescriptionAttribute;
	using By = MbUnit.Framework.AuthorAttribute;
	using Tag = MbUnit.Framework.CategoryAttribute;
	#endregion

	[
		Describe(typeof(StatusClient)),
		InContext("should perform its specified behavor."),
		Tag("Functional"),
		Ignore,
		By("Michael Herndon", "mherndon@opensourceconnections.com", "www.amptools.net")
	]
	public class StatusClientSpec : Spec
	{

		[It, Should(" retrieve the specified user's timeline ")]
		public void GetUserTimeline()
		{
			StatusClient client = Twitter.CreateStatusClient();
			Status[] tweets = client.GetUserTimeline();
			tweets.ShouldNotBeNull();
			tweets.Length.ShouldBeGreaterThan(0);
		}


		[It, Should(" retrieve the specified user friend's timeline. ")]
		public void GetFriendTimeline()
		{
			StatusClient client = Twitter.CreateStatusClient();
			Status[] tweets = client.GetFriendsTimeline();
			tweets.ShouldNotBeNull();
			tweets.Length.ShouldBeGreaterThan(0);
		}

		[It, Should(" retrieve the public timeline. ")]
		public void GetPublicTimeline()
		{
			StatusClient client = Twitter.CreateStatusClient();
			Status[] tweets = client.GetPublicTimeline();
			tweets.ShouldNotBeNull();
			tweets.Length.ShouldBeGreaterThan(0);
		}

		[It, Should(" retrieve all the replies. ")] 
		public void GetReplies()
		{
			StatusClient client = Twitter.CreateStatusClient();
			Status[] tweets = client.GetReplies();
			tweets.ShouldNotBeNull();
			tweets.Length.ShouldBeGreaterThan(0);
		}


		[It, Should(" create a tweet, show it, then destroy it.. muahahahah ")]
		public void UpdateShowAndDestroy()
		{
			StatusClient client = Twitter.CreateStatusClient();
			string test = "this is a test";
			Status tweet = client.Create(test);
			tweet.ShouldNotBeNull();
			if (!string.IsNullOrEmpty(tweet.Error) && tweet.Error.Length > 0)
				throw new Exception(tweet.Error);
			int id = tweet.Id.Value;
			

			Status tweet2 = client.Show(id);
			tweet2.Id.ShouldBe(id);
			tweet2.Text.ShouldBe(test);

			client.Destroy(id);
		}

	
	}
}
